<?php

$lang_from_to = str_replace("<#1>", "1.7.2", $lang_update['update_from_to']);
$lang_from_to = str_replace("<#2>", "2.0.0", $lang_from_to);

if($_GET['step']=="2"){
	mysql_query("UPDATE {$db_prefix}settings SET max_version='$ver_name'");
	
	mysql_query("INSERT INTO `{$db_prefix}seo` (`seo_off`, `seo_on`) VALUES
	('index.php?page=gallery&act=view-cat&id=$1&pg=$2', 'gallery/view-cat/([0-9]+)/([0-9]+)'),
	('index.php?page=gallery&act=my-images&sub=edit-image&id=$1', 'gallery/my-images/edit-image/([0-9]+)'),
	('index.php?page=gallery&act=my-images&sub=delete-image&id=$1', 'gallery/my-images/delete-image/([0-9]+)'),
	('index.php?page=gallery&act=$1&id=$2', 'gallery/([a-zA-Z\-]+)/([0-9]+)'),
	('index.php?page=gallery&act=$1', 'gallery/([a-zA-Z\-]+)'),
	('index.php?page=gallery', 'gallery'),
	('index.php?page=admin&act=gallery&sub=edit_image&id=$1', 'admin/gallery/edit_image/([0-9]+)'),
	('index.php?page=admin&act=gallery&sub=delete_image&id=$1', 'admin/gallery/delete_image/([0-9]+)'),
	('index.php?page=admin&act=gallery&sub=edit_album&id=$1', 'admin/gallery/edit_album/([0-9]+)'),
	('index.php?page=admin&act=gallery&sub=delete_album&id=$1', 'admin/gallery/delete_album/([0-9]+)'),
	('index.php?page=admin&act=gallery&sub=add_album', 'admin/gallery/add_album'),
	('index.php?page=admin&act=gallery', 'admin/gallery'),
	('index.php?page=admin&act=blocks', 'admin/blocks'),
	('index.php?page=admin&act=blocks&sub=edit_block&id=$1', 'admin/blocks/edit_block/([0-9]+)'),
	('index.php?page=admin&act=blocks&sub=delete_block&id=$1', 'admin/blocks/delete_block/([0-9]+)'),
	('index.php?page=admin&act=blocks&sub=add_block', 'admin/blocks/add_block');");
	
	mysql_query("ALTER TABLE `{$db_prefix}settings` ADD `tags` INT( 10 ) NOT NULL DEFAULT '1';");
	
	mysql_query("CREATE TABLE `{$db_prefix}blocks` (
	`id` int(11) NOT NULL auto_increment,
	`title` varchar(255) NOT NULL default '',
	`contant` text NOT NULL,
	`block_file` varchar(255) NOT NULL default '',
	PRIMARY KEY  (`id`)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_general_ci");
	
	mysql_query("INSERT INTO `{$db_prefix}blocks` (`id`, `title`, `contant`, `block_file`) VALUES 
	(1, '{$lang['database_block1']}', '<img src=\"images/forums/vector.jpg\" border=\"0\" />', '0'),
	(2, '{$lang['database_block2']}', '', 'facebook');");

	$array_table = array(
		"Gallery ".$lang_update['upd_done']."",
		"Add_album ".$lang_update['upd_done']."",
		"Edit_album ".$lang_update['upd_done']."",
		"Modules ".$lang_update['upd_done']."",
		"Permissions ".$lang_update['upd_done']."",
		"Report ".$lang_update['upd_done']."",
		"Settings ".$lang_update['upd_done']."",
		"Themes ".$lang_update['upd_done']."",
		"Ranks ".$lang_update['upd_done']."",
		"Censor ".$lang_update['upd_done']."",
		"Attachments ".$lang_update['upd_done']."",
		"Groups ".$lang_update['upd_done']."",
		"Moderate ".$lang_update['upd_done']."",
		"Blocks ".$lang_update['upd_done']."",
		"<br /><br /><div align='center' style='color:red;'>".$lang_update['upd_succ']."</div>",
		"<div align='center'><img src='http://www.max4dev.com/logo/upgrade_2.0.0.png' /></div>"
	);
	
	$html_ok = "<form method='post' onsubmit='return check_license()' action='upgrade.php'>";
	$html_ok .= "<br /><br /><div style='font: 16px Arial; font-weight: bold;'>";
	$html_ok .= "<center><input type='submit' class='img-submit' value='".$lang['submit_ok']."'/></center>";
	$html_ok .= "</form>";
	
}else{
	echo "<form method='post' onsubmit='return check_license()' action='upgrade.php?step=2'>";
	echo "<br /><br /><br /><br /><div style='font: 16px Arial; font-weight: bold;'>";
	echo "<center>".$lang_from_to."</center></div><br /><br /><br /><br />";
	echo "<input type='hidden' name='ver_name' value='2.0.0'/><div>";
	echo "<center><input type='submit' class='img-submit' value='".$lang['submit_ok']."'/></center>";
	echo "</form>";
}
?>